package cn.mesmile.thread.single;

import cn.hutool.core.collection.ConcurrentHashSet;
import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.ThreadUtil;

/**
 * @author zb
 * @date 2020/12/31 14:36
 * @Description
 */
public class SingleInstanceTest {

    public static void main(String[] args) {
        ConcurrentHashSet<String> strings = new ConcurrentHashSet<>();
        // 并发测试工具
        ConcurrencyTester concurrencyTester = ThreadUtil.concurrencyTest(1000, new Runnable() {
            @Override
            public void run() {
                SingleInstance singleInstance = SingleInstance.getSingleInstance();
                strings.add(singleInstance.toString());
            }
        });
        int size = strings.size();
        System.out.println("size = " + size);
        for (String string : strings) {
            System.out.println("string = " + string);
        }
        // 获取总的执行时间，单位毫秒
        Console.log(concurrencyTester.getInterval());
    }

}
